package com.xlh.app;

import com.xlh.api.Dictionary;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import ro.fortsoft.pf4j.DefaultExtensionFinder;
import ro.fortsoft.pf4j.DefaultPluginManager;
import ro.fortsoft.pf4j.ExtensionFinder;
import ro.fortsoft.pf4j.PluginManager;

import java.util.List;

/**
 * @author xulihua
 */
@SpringBootApplication
public class ServiceAppApplication {

    public static void main(String[] args) {
       /*final PluginManager pluginManager = new DefaultPluginManager(){
           @Override
           protected ExtensionFinder createExtensionFinder() {
               DefaultExtensionFinder extensionFinder = (DefaultExtensionFinder) super.createExtensionFinder();
               extensionFinder.addServiceProviderExtensionFinder(); // to activate "HowdyGreeting" extension

               return extensionFinder;
           }
       };*/

        final PluginManager pluginManager = new DefaultPluginManager();

        // 加载插件
        pluginManager.loadPlugins();
        // 启动插件
        pluginManager.startPlugins();
        // 获取扩展点的扩展
        List<Dictionary> extensions = pluginManager.getExtensions(Dictionary.class);
        for (Dictionary dictionary : extensions
        ) {
            String xml = dictionary.getDefinition("xml");
            if (null != xml) {
                System.out.println("解析结果:" + xml);
                break;
            }
        }
    }
}
